home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Tool Chest / Dev.CD Feb 97 TC.toast / Sample Code / Networking / Http Server / •OT_Classes / TNetworkException.h < prev    next >
Encoding:
Text File  |  1996-01-11  |  2.2 KB  |  67 lines  |  [TEXT/CWIE]

  1. //    TNetworkException.h - Macintosh OpenTransport Exception class object
  2. // 
  3. // Apple Macintosh Developer Technical Support
  4. // Written by:  Vinne Moscaritolo
  5. //
  6. //  Copyright (work in progress)  Apple Computer, Inc All rights reserved.
  7. //
  8. // You may incorporate this sample code into your applications without
  9. // restriction, though the sample code has been provided "AS IS" and the
  10. // responsibility for its operation is 100% yours.  However, what you are
  11. // not permitted to do is to redistribute the source as "DSC Sample Code"
  12. // after having made changes. If you're going to re-distribute the source,
  13. // we require that you make it clear in the source that the code was
  14. // descended from Apple Sample Code, but that you've made changes.
  15. // 
  16.  
  17. #ifndef _H_TNETWORKEXCEPTION
  18. #define _H_TNETWORKEXCEPTION
  19.  
  20. #include "TMacException.h"
  21.  
  22.  
  23. //
  24. // TNetworkException  - OpenTransport Network Exception 
  25. //
  26. class TNetworkException : public TMacException
  27. {
  28. public:
  29. //     CONSTRUCTORS AND DESTRUCTORS
  30.     TNetworkException(const char *theMessage, const OSStatus theStatus) :
  31.                     fStatus( theStatus),
  32.                     TMacException(theMessage, -1, "NO FILE SPECIFIED", 0L)
  33.                     {};
  34.                     
  35.     TNetworkException(const char *theMessage, const OSStatus theStatus, const char *theFileName, const long theLineNumber) :
  36.                     fStatus( theStatus),
  37.                     TMacException(theMessage, -1, theFileName, theLineNumber)
  38.                     {};
  39.  
  40. // ACCESSORS and MUTATORS    
  41.     const OSStatus    GetOSStatus(void)        { return fStatus;};
  42.     
  43. // PROTECTED FIELDS
  44. protected:
  45.     const OSStatus fStatus;
  46.  
  47. };
  48.  
  49. // Utility Macros
  50.  
  51. #define ThrowIfOTErr(_err_)                                        \
  52.         if (_err_ != noErr)                                            \
  53.             throw TNetworkException( "NO MESSAGE SPECIFIED", (_err_), __FILE__, __LINE__)     
  54.  
  55. #define ThrowIfOTInvalidRef( _val_ )                                        \
  56.         if ( (_val_) == (EndpointRef) kOTInvalidRef )                                        \
  57.             throw TMacException( "INVALID PROVIDER REF RETURNED" ,0 , __FILE__, __LINE__)     
  58.  
  59. #define ThrowIfOTInvalidConfig( _val_ )                                        \
  60.         if ( (_val_) == kOTInvalidConfigurationPtr )                                        \
  61.             throw TMacException( "INVALID CONFIG RETURNED" ,0 , __FILE__, __LINE__)     
  62.  
  63. #define ThrowOTErr(_err_)                                        \
  64.             throw TNetworkException( "NO MESSAGE SPECIFIED", (_err_), __FILE__, __LINE__)     
  65.  
  66. #endif
  67.